package com.ayic.garbagerecycle.mapper;

import com.ayic.garbagerecycle.pojo.WasteTrend;
import org.apache.ibatis.annotations.*;

import java.util.Map;

/**
 * @author AyiC416
 * @ClassName garbagerecycle
 * @date 2025/5/21
 * @Description TODO
 */

@Mapper
public interface TrendMapper {

    @Insert("INSERT INTO waste_trends (station_id, trend_description, created_at, updated_at) " +
            "VALUES (#{wasteTrend.stationId}, #{wasteTrend.trendDescription}, #{wasteTrend.createdAt}, #{wasteTrend.updatedAt})")
    @Options(useGeneratedKeys = true, keyProperty = "wasteTrend.trendId")
    int insertWasteTrend(@Param("wasteTrend") WasteTrend wasteTrend);

    @Select("SELECT trend_description AS trendDescription, created_at AS createdAt FROM waste_trends WHERE station_id = #{stationId} ORDER BY created_at DESC LIMIT 1")
    String getNewestReport(Integer stationId);
}
